/*

	Game.h
	
	Wrapper class for basic game functionality.
	Everything related to initialization, clean up
	and the game kernel itself is contained within
	this class.
	
	Written by Sigurd Suhm 2009

*/

#ifndef _GAME_H
#define _GAME_H

// Includes
#include "IDevice.h"			// Graphics device interface
#include "EventHandler.h"		// Event handler
#include "InputDevice.h"		// Input device header
#include "Logger.h"				// Logging functionality
#include "IKernelComponent.h"	// Kernel components
#include "Timer.h"				// Timer class header
#include "SceneManager.h"		// Scene manager header

#include <vector>		// STL vector class header

namespace EraAstral
{
	namespace core
	{
		// Game wrapper class
		class Game : public IHasEvents
		{
			private:
				// Graphics device
				graphics::IDevice	*m_device;
				// Game event handler
				EventHandler		*m_eventHandler;
				// Game input device
				InputDevice			*m_input;
				// Game log handler
				Logger				*m_logger;
				// Game timer
				Timer				*m_timer;
				// Scene manager
				SceneManager		*m_smgr;
				
				// Vector holding game components
				std::vector<IKernelComponent *> components;
				
				// Indicates whether the game should keep running
				bool m_shouldRun;
				
				// Vertical Synchronization enabled?
				bool	m_vSync;
				// Screen refresh rate
				unsigned int	m_screenRefresh;

				// Game specific methods
				int Initialize();		// Game initialization
				void Update();			// Game update logic - Mainly CPU load
				void Render();			// Game rendering logic - Mainly GPU load
				
				// Utility methods
				void ApplyVSync();		// Waits for next screen refresh before moving to next frame

			public:
				// Default game constructor
				Game();
				// Default game destructor
				~Game();
				
				// Public methods
				void Run();			// Initializes the game and starts the game kernel
				void Exit();		// Notifies the game that it should exit the kernel
				
				// Override from IHasEvents
				void ProcessEventSignal(const Event *event);
				
				// Accessors
				Logger		*GetLogger() const;		// Gets the game logger
		};
	}
}

#endif		// _GAME_H
